home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
gnu
/
updates
/
update24.zoo
/
gdbm
/
diffs2
next >
Wrap
Text File
|
1992-08-13
|
5KB
|
186 lines
*** 1.2 1992/04/07 21:55:43
--- gdbmreorg.c 1992/08/14 03:18:41
***************
*** 24,29 ****
--- 24,32 ----
Western Washington University
Bellingham, WA 98226
phone: (206) 676-3035
+
+ Cache and walking file descriptor patch applied
+ e-mail: phil@compnews.co.uk
************************************************************************/
***************
*** 74,79 ****
--- 77,83 ----
gdbm_file_info *new_dbf; /* The new file. */
char *new_name; /* A temporary name. */
int len; /* Used in new_name construction. */
+ int new_desc; /* Used to avoid walking file desc */
datum key, nextkey, data; /* For the sequential sweep. */
struct stat fileinfo; /* Information about the file. */
int index; /* Use in moving the bucket cache. */
***************
*** 112,118 ****
if (new_dbf == NULL)
{
gdbm_errno = GDBM_REORGANIZE_FAILED;
! free (new_name);
return -1;
}
--- 116,122 ----
if (new_dbf == NULL)
{
gdbm_errno = GDBM_REORGANIZE_FAILED;
! free (new_name); /* free up the space allocated to new_name */
return -1;
}
***************
*** 131,138 ****
gdbm_close (new_dbf);
gdbm_errno = GDBM_REORGANIZE_FAILED;
unlink (new_name);
return -1;
! };
}
else
{
--- 135,143 ----
gdbm_close (new_dbf);
gdbm_errno = GDBM_REORGANIZE_FAILED;
unlink (new_name);
+ free(new_name); /* free up the space allocated to new_name */
return -1;
! }
}
else
{
***************
*** 140,145 ****
--- 145,151 ----
gdbm_close (new_dbf);
gdbm_errno = GDBM_REORGANIZE_FAILED;
unlink (new_name);
+ free(new_name); /* free up the space allocated to new_name */
return -1;
}
nextkey = gdbm_nextkey (dbf, key);
***************
*** 154,159 ****
--- 160,167 ----
{
gdbm_errno = GDBM_REORGANIZE_FAILED;
gdbm_close (new_dbf);
+ unlink (new_name);
+ free(new_name); /* free up the space allocated to new_name */
return -1;
}
#endif
***************
*** 160,172 ****
/* Fix up DBF to have the correct information for the new file. */
UNLOCK_FILE(dbf);
! close (dbf->desc);
#ifdef atarist
close(new_dbf->desc);
if (rename (new_name, dbf->name) != 0)
{
gdbm_errno = GDBM_REORGANIZE_FAILED;
gdbm_close (new_dbf);
return -1;
}
if((new_dbf->desc = open(dbf->name, O_RDWR)) < 0)
--- 168,198 ----
/* Fix up DBF to have the correct information for the new file. */
UNLOCK_FILE(dbf);
!
! #ifndef atarist
! /* phil - don't close the descriptor, dup it... */
! /* close (dbf->desc); */
! if ((new_desc = dup2(new_dbf->desc, dbf->desc)) < 0)
! {
! gdbm_close(new_dbf);
! gdbm_errno = GDBM_REORGANIZE_FAILED;
! unlink (new_name); /* unlink the created file */
! free(new_name); /* free up the space allocated to new_name */
! return -1;
! }
! /* ...and reassign */
! dbf->desc = new_desc;
! #endif
!
#ifdef atarist
+ close (dbf->desc);
close(new_dbf->desc);
if (rename (new_name, dbf->name) != 0)
{
gdbm_errno = GDBM_REORGANIZE_FAILED;
gdbm_close (new_dbf);
+ unlink(new_name);
+ free(new_name); /* free up the space allocated to new_name */
return -1;
}
if((new_dbf->desc = open(dbf->name, O_RDWR)) < 0)
***************
*** 173,178 ****
--- 199,205 ----
{
gdbm_errno = GDBM_REORGANIZE_FAILED;
gdbm_close (new_dbf);
+ free(new_name); /* free up the space allocated to new_name */
return -1;
}
lseek(new_dbf->desc, 0L, SEEK_END);
***************
*** 188,199 ****
free (dbf->bucket_cache[index].ca_data.dptr);
}
! dbf->desc = new_dbf->desc;
dbf->header = new_dbf->header;
dbf->dir = new_dbf->dir;
dbf->bucket = new_dbf->bucket;
dbf->bucket_dir = new_dbf->bucket_dir;
! dbf->cache_entry = new_dbf->cache_entry;
dbf->last_read = new_dbf->last_read;
for (index = 0; index < CACHE_SIZE; index++)
dbf->bucket_cache[index] = new_dbf->bucket_cache[index];
--- 215,234 ----
free (dbf->bucket_cache[index].ca_data.dptr);
}
! #ifndef atarist
! /* dbf->desc = new_dbf->desc; - now dup */
! #else
! dbf->desc = new_dbf->desc; /* the newly opened file */
! #endif
!
dbf->header = new_dbf->header;
dbf->dir = new_dbf->dir;
dbf->bucket = new_dbf->bucket;
dbf->bucket_dir = new_dbf->bucket_dir;
! /* phil - do not assign the cache, it will/may be different... */
! /* dbf->cache_entry = new_dbf->cache_entry; */
! /* use the new cache */
! dbf->cache_entry = &dbf->bucket_cache[new_dbf->last_read];
dbf->last_read = new_dbf->last_read;
for (index = 0; index < CACHE_SIZE; index++)
dbf->bucket_cache[index] = new_dbf->bucket_cache[index];
***************
*** 206,211 ****
--- 241,248 ----
/* Make sure the new database is all on disk. */
fsync (dbf->desc);
+
+ free(new_name); /* free up space allocated to new name */
return 0;
}